﻿Public Class frmSET
    Private mIsSave As Boolean = False

    Public ReadOnly Property isSave() As Boolean
        Get
            Return mIsSave
        End Get
    End Property


    Private Sub frmSET_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Settings.Item("CEUid") = String.Empty Then
            txtCEUid.Text = "FNCUser_tw"
        Else
            txtCEUid.Text = My.Settings.Item("CEUid")
        End If
        If My.Settings.Item("CEPwd") = String.Empty Then
            txtCEPwd.Text = ""
        Else
            txtCEPwd.Text = My.Settings.Item("CEPwd")
        End If
        If My.Settings.Item("CEIP") = String.Empty Then
            txtCEIP.Text = "172.22.246.141"
        Else
            txtCEIP.Text = My.Settings.Item("CEIP")
        End If
        If My.Settings.Item("CEPort") = String.Empty Then
            txtCEPort.Text = "9081"
        Else
            txtCEPort.Text = My.Settings.Item("CEPort")
        End If
        If My.Settings.Item("ISLibrary") = String.Empty Then
            txtISLibrary.Text = "DefaultIMS:HIBANK:FileNET"
        Else
            txtISLibrary.Text = My.Settings.Item("ISLibrary")
        End If
        If My.Settings.Item("ISUid") = String.Empty Then
            txtISUid.Text = "SysAdmin"
        Else
            txtISUid.Text = My.Settings.Item("ISUid")
        End If
        If My.Settings.Item("ISPwd") = String.Empty Then
            txtISPwd.Text = "SysAdmin"
        Else
            txtISPwd.Text = My.Settings.Item("ISPwd")
        End If
        If My.Settings.Item("FileNetDB_IP") = String.Empty Then
            txtDBIP.Text = "172.22.243.82"
        Else
            txtDBIP.Text = My.Settings.Item("FileNetDB_IP")
        End If
        If My.Settings.Item("FileNetDB_Uid") = String.Empty Then
            txtDBUid.Text = "f_maint"
        Else
            txtDBUid.Text = My.Settings.Item("FileNetDB_Uid")
        End If
        If My.Settings.Item("FileNetDB_PWD") = String.Empty Then
            txtDBPwd.Text = "f_maint"
        Else
            txtDBPwd.Text = My.Settings.Item("FileNetDB_PWD")
        End If
        If My.Settings.Item("rows") = String.Empty Then
            txtRows.Text = "100"
        Else
            txtRows.Text = My.Settings.Item("rows")
        End If
        If My.Settings.Item("DocStart") = String.Empty Then
            txtDocStart.Text = "1"
        Else
            txtDocStart.Text = My.Settings.Item("DocStart")
        End If
        If My.Settings.Item("DocEnd") = String.Empty Then
            txtDocEnd.Text = "0"
        Else
            txtDocEnd.Text = My.Settings.Item("DocEnd")
        End If
        If My.Settings.CurrDoc = String.Empty Then
            txtCurrDoc.Text = "0"
        Else
            txtCurrDoc.Text = My.Settings.Item("CurrDoc")
        End If

        If My.Settings.Item("LogFolder") = "" Then
            txtLogFolder.Text = Application.StartupPath.TrimEnd("\") & "\TransferLog"
        Else
            txtLogFolder.Text = My.Settings.LogFolder
        End If
        If My.Settings.Item("xmlFolder") = "" Then
            txtXMLFolder.Text = Application.StartupPath.TrimEnd("\") & "\IStoCE.xml"
        Else
            txtXMLFolder.Text = My.Settings.xmlFolder
        End If

        If My.Settings.StartTime = "" Then
            txtStart.Text = "22:00:00"
        Else
            txtStart.Text = My.Settings.StartTime
        End If

        If My.Settings.StartTime = "" Then
            txtStop.Text = "12:00:00"
        Else
            txtStop.Text = My.Settings.StopTime
        End If

        If My.Settings.FileNetBackupTime = "" Then
            txtBackupTime.Text = "02:45:00"
        Else
            txtBackupTime.Text = My.Settings.FileNetBackupTime
        End If

        If My.Settings.BackupDuration = "" Then
            Me.backupduration.Text = "60"
        Else
            backupduration.Text = My.Settings.BackupDuration
        End If

    End Sub



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click

        If txtDocEnd.Text = "0" OrElse txtDocEnd.Text = "" Then
            MessageBox.Show("Wrong End Doc Number ")
            Exit Sub
        End If

        My.Settings.Item("CEUid") = txtCEUid.Text
        My.Settings.Item("CEPwd") = txtCEPwd.Text
        My.Settings.Item("CEIP") = txtCEIP.Text
        My.Settings.Item("CEPort") = txtCEPort.Text
        My.Settings.Item("ISLibrary") = txtISLibrary.Text
        My.Settings.Item("ISUid") = txtISUid.Text
        My.Settings.Item("ISPwd") = txtISPwd.Text
        My.Settings.Item("FileNetDB_IP") = txtDBIP.Text
        My.Settings.Item("FileNetDB_Uid") = txtDBUid.Text
        My.Settings.Item("FileNetDB_PWD") = txtDBPwd.Text
        My.Settings.Item("rows") = txtRows.Text
        My.Settings.Item("DocStart") = txtDocStart.Text
        My.Settings.Item("DocEnd") = txtDocEnd.Text
        My.Settings.Item("CurrDoc") = txtCurrDoc.Text
        My.Settings.Item("LogFolder") = txtLogFolder.Text
        My.Settings.Item("xmlFolder") = txtXMLFolder.Text
        My.Settings.StartTime = txtStart.Text
        My.Settings.StopTime = txtStop.Text
        My.Settings.FileNetBackupTime = txtBackupTime.Text
        My.Settings.BackupDuration = backupduration.Text
        My.Settings.Save()

        btnStart.Enabled = True
        'mIsSave = True
        'Me.Hide()
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        mIsSave = False
        Me.Hide()
    End Sub

    Private Sub btnStart_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnStart.Click
        mIsSave = True
        Me.Hide()
    End Sub

    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
        txtCurrDoc.Text = "0"
        My.Settings.CurrDoc = "0"
        My.Settings.Save()
    End Sub
End Class